#include "StdAfx.h"
#include "ParticleManagerForm.h"
#include "OgreInit.h"
#include "PropertyBoxForm.h"
#include "ParticleProperties.h"

using namespace particleEditorCli;


ParticleManagerForm::ParticleManagerForm(void)
{
	InitializeComponent();
	mInstance = this;

	/*ParticleSystemManager::ParticleSystemTemplateIterator::iterator it;
	ParticleSystemManager::ParticleSystemTemplateIterator itt = ParticleSystemManager::getSingletonPtr()->getTemplateIterator();
	for( it = itt.begin(); it!= itt.end(); ++it)
	{
		mTreeView->Nodes[0]->Nodes->Add(gcnew System::String(f->getName().c_str() ));
	}*/

	
	//	AfterSelect += gcnew TreeViewEventHandler(this, &ParticleManagerForm::treeViewAfterSelectCallback);
	mTreeView->AfterSelect += gcnew TreeViewEventHandler(this, &ParticleManagerForm::treeViewAfterSelectCallback);
	mTreeView->Click += gcnew EventHandler(this, &ParticleManagerForm::treeViewClickCallback);
	

}

ParticleManagerForm::~ParticleManagerForm()
{
	if (components)
	{
		delete components;
	}
}

void ParticleManagerForm::treeViewClickCallback(Object^sender, EventArgs^ e)
{
PropertyBoxForm::Instance->setObject(gcnew ParticleEmitterProperties(OgreInit::getSingletonPtr()->ps->getEmitter(0)));//getParticle(0)));
}

void ParticleManagerForm::treeViewAfterSelectCallback(Object^sender, TreeViewEventArgs^ e)
{
	
	//if(e->Node == mTreeView->Nodes[0]) return;
	
	/*char* c = particleEditorCli::ConvertNetStringToChar(e->Node->Text);
	ParticleSystem* ps;
	// create some nice fireworks and place it at the origin
	static int oid;
	ps = OgreInit::getSingletonPtr()->getSceneManager()->createParticleSystem(Ogre::StringConverter::toString(oid++),c);
	OgreInit::getSingletonPtr()->getSceneManager()->getRootSceneNode()->attachObject(ps);*/
}

void ParticleManagerForm::InitializeComponent(void)
{
	this->components = (gcnew System::ComponentModel::Container());
	System::Windows::Forms::TreeNode^  treeNode1 = (gcnew System::Windows::Forms::TreeNode(L"ParticleFx"));
	System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(ParticleManagerForm::typeid));
	this->mTreeView = (gcnew System::Windows::Forms::TreeView());
	this->mToolStrip = (gcnew System::Windows::Forms::ToolStrip());
	this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
	this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
	this->mContextMenuStrip = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
	this->mToolStrip->SuspendLayout();
	this->SuspendLayout();
	// 
	// mTreeView
	// 
	this->mTreeView->ContextMenuStrip = this->mContextMenuStrip;
	this->mTreeView->Dock = System::Windows::Forms::DockStyle::Fill;
	this->mTreeView->Location = System::Drawing::Point(0, 25);
	this->mTreeView->Name = L"mTreeView";
	treeNode1->Name = L"Node0";
	treeNode1->Text = L"ParticleFx";
	this->mTreeView->Nodes->AddRange(gcnew cli::array< System::Windows::Forms::TreeNode^  >(1) {treeNode1});
	this->mTreeView->Size = System::Drawing::Size(284, 237);
	this->mTreeView->TabIndex = 0;
	// 
	// mToolStrip
	// 
	this->mToolStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->toolStripButton1, 
		this->toolStripButton2});
	this->mToolStrip->Location = System::Drawing::Point(0, 0);
	this->mToolStrip->Name = L"mToolStrip";
	this->mToolStrip->Size = System::Drawing::Size(284, 25);
	this->mToolStrip->TabIndex = 1;
	this->mToolStrip->Text = L"toolStrip1";
	// 
	// toolStripButton1
	// 
	this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
	this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton1.Image")));
	this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
	this->toolStripButton1->Name = L"toolStripButton1";
	this->toolStripButton1->Size = System::Drawing::Size(23, 22);
	this->toolStripButton1->Text = L"mToolStripButton";
	// 
	// toolStripButton2
	// 
	this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
	this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton2.Image")));
	this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
	this->toolStripButton2->Name = L"toolStripButton2";
	this->toolStripButton2->Size = System::Drawing::Size(23, 22);
	this->toolStripButton2->Text = L"mToolStripButton";
	// 
	// mContextMenuStrip
	// 
	this->mContextMenuStrip->Name = L"mContextMenuStrip";
	this->mContextMenuStrip->Size = System::Drawing::Size(61, 4);
	// 
	// ParticleManagerForm
	// 
	this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
	this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
	this->ClientSize = System::Drawing::Size(284, 262);
	this->Controls->Add(this->mTreeView);
	this->Controls->Add(this->mToolStrip);
	this->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
		static_cast<System::Byte>(0)));
	this->HideOnClose = true;
	this->Name = L"ParticleManagerForm";
	this->Text = L"ParticleManagerForm";
	this->mToolStrip->ResumeLayout(false);
	this->mToolStrip->PerformLayout();
	this->ResumeLayout(false);
	this->PerformLayout();

}

ParticleManagerForm^ ParticleManagerForm::Instance::get()
{
	return mInstance;
}
